package com.lz.autotest.project.testmanage.reportmanage.domain;

import com.lz.autotest.project.system.domain.SysConfig;
import com.lz.autotest.project.system.service.ISysConfigService;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

/**
 * @author: X
 * @date: Created in 2023/10/10 10:12
 * @Description: 请求超时时间常量，项目初始化查询数据库，修改系统参数时更新
 */
@Component
public class TimeOutContant {

    public static Long TIME_OUT;

    public static String CONFIG_KEY = "sys.request.timeOut";

    @Resource
    private ISysConfigService configService;


    @PostConstruct
    private void intiTimeOut() {
        SysConfig sysConfig = new SysConfig();
        sysConfig.setConfigKey(CONFIG_KEY);
        List<SysConfig> sysConfigs = configService.selectConfigList(sysConfig);
        TIME_OUT = Long.parseLong(sysConfigs.get(0).getConfigValue());
    }

    public static void updateTimeOut(Long timeOut) {
        TIME_OUT = timeOut;
    }

}
